/**
 * 
 */
package sequences.editgraph;

public class ArcExtended<E extends EditGraph<E, ? extends Extender<E>>> extends
		ArcAbstractImpl<E>
{
	Vertex<E>	beginVertex;

	public ArcExtended(Vertex<E> beginVertex, Vertex<E> endVertex, int weight)
			throws EGInvalidArcException, EGInvalidVertexException
	{
		super(endVertex, weight);
		this.beginVertex = beginVertex;
		if (!getEditGraph().isValidVertex(beginVertex))
		{
			throw new EGInvalidVertexException(beginVertex);
		}
		if (!getEditGraph().existsExtendedArc(
			new VertexRange<E>(beginVertex, endVertex)))
		{
			throw new EGInvalidArcException(EditGraph.EXTENDED,
				"Can not create extended arc on the vertex " + this.endVertex);
		}
	}

	public Vertex<E> getBeginVertex()
	{
		return beginVertex;
	}

	public VertexRange<E> getRange()
	{
		try
		{
			return new VertexRange<E>(getBeginVertex(), getEndVertex());
		}
		catch (EGInvalidVertexException e)
		{
			e.printStackTrace();
			throw new EGInternalException();
		}
	}
}